// pages/my/helpDetail/helpDetail.js

var app = getApp();

var util = require("../../../utils/util");
var md5 = require("../../../utils/md5");
var wxParse = require("../../../utils/wxParse/wxParse");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    okShow: true,
    noShow: true,
    wholeImg:'',//从banner点进来，页面是整张图片
    banner:false,//是否是从首页banner点进来
  },
  okClick() {
    if (this.data.noShow) {
      this.setData({
        okShow: false,
      });
    }
  },
  noClick() {
    if (this.data.okShow) {
      this.setData({
        noShow: false,
      });
    }
  },
  goto() {
    wx.navigateTo({
      url: "../feedbackList/feedbackList",
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.id, "传入");
    var that = this;
    var id = options.id;
    if (options.from == 'banner') {
      that.setData({
        banner:true
      })
      var url="mobile/topicsinfo?id="+options.id
      var that = this;
      var secret = app.globalData.md5secret;
      var timestamp = new Date().getTime();
      var stamp = secret + "timestamp=" + timestamp;
      var signature = md5.hexMD5(stamp);
      var temp = {
        timestamp: timestamp,
        signature: signature,
      };
      util.postRes(url, temp, function (res) {
        console.log(res.data)
        that.setData({
          wholeImg:res.data.contentimg,
        });
        wx.setNavigationBarTitle({
          title: res.data.name
        })
      });
    } else {
      var url = "/xchelpdocinfo";
      var secret = app.globalData.md5secret;
      var timestamp = new Date().getTime();
      var stamp = secret + "timestamp=" + timestamp;
      var signature = md5.hexMD5(stamp);
      var temp = {
        id: options.id,
        timestamp: timestamp,
        signature: signature,
      };
      util.postRes(url, temp, function (res) {
        console.log(res);
        console.log(
          wxParse.wxParse("article", "html", res.data.answer, that, 5)
        );
        // that.setData({
        //   currentId: id,
        //   article: wxParse.wxParse("article", "html",res.data.answer, that, 5),
        // });
      });
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});
